<template>
  <div>
    <el-table :data="rolelist" style="width: 100%">
      <el-table-column prop="rolename" label="名称" width="180">
      </el-table-column>
      <el-table-column label="状态" width="180">
        <template slot-scope="scope">
          <el-tag :type="scope.row.status == 1 ? 'success' : 'warning'">{{
            scope.row.status == 1 ? "启用" : "禁用"
          }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="small" @click="edit(scope.row)">编辑</el-button
          ><el-button type="danger" size="small" @click="remake(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: ["rolelist"],
  data() {
    return {};
  },
  computed: {},
  created() {},
  mounted() {},
  watch: {},
  methods: {
    edit(obj) {//编辑
      this.$emit('editrole',obj)
    },
    remake(obj) {// 删除
      
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {  // 删除提示框
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {

          this.$api.postroledelete({ id: obj.id }).then((res) => {   // 请求删除接口
            this.$message({
              type: "success",
              message: "删除成功!",
            });
            this.$emit('getlist')  // 调用获取接口实现页面改变
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
  components: {},
};
</script>

<style scoped lang="scss">
::v-deep .el-table {
  margin-top: 20px;
}
</style>
